<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.PreparedStatement" %><%--
  Created by IntelliJ IDEA.
  User: 113
  Date: 2020/10/21
  Time: 8:04
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    Class.forName("com.mysql.jdbc.Driver");//报错，说明驱动包没有完成
//建立数据库连接  18.3.22.1
    String url ="jdbc:mysql://localhost:3306/book";

    Connection connection = DriverManager.getConnection(url,"root","root");
    String sql = "delete from user where id = ?";
    PreparedStatement pstm = connection.prepareStatement(sql);
    int id = Integer.parseInt(request.getParameter("id"));
    pstm.setInt(1,id);
    int count = pstm.executeUpdate();
    if(count > 0){
        out.print("删除成功");
    }else{
        out.print("删除失败");
    }
%>
